const {ccclass, property} = cc._decorator;

/**主场景提示脚本 */
@ccclass
export default class NoticeTip extends cc.Component {

    /**游戏场景提示的容器 */
    guohu: cc.Node = null;
    /**提示的文字节点 */
    info: cc.Label = null;

    /**接收到过胡时显示的时间 */
    guoHuTime = -1;
    onLoad() {
        this.guohu = cc.find('Canvas/tip_notice');
        this.guohu.active = false;

        this.info = cc.find('Canvas/tip_notice/info').getComponent(cc.Label);

        this.node.on(cc.vv.game_event_map.PUSH_NOTICE, (data) => {
            const data1 = data.detail;
            this.guohu.active = true;
            this.guoHuTime = data1.time;
            this.info.string = data1.info;
        });
    }

    update(dt: number){
        if(this.guoHuTime > 0){
            this.guoHuTime -= dt;
            if(this.guoHuTime < 0){
                this.guohu.active = false;
            }
        }
    }
}
